package com.example.excel.pojo;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class BaseExcel<T> {

    private String filePath;

    private String fileName;

    public BaseExcel() {
    }

    public BaseExcel(String filePath) {
        setFilePath(filePath);
    }

    private List<BaseSheet<T>> sheetList;

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
        this.fileName = new File(filePath).getName();
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public List<BaseSheet<T>> getSheetList() {
        return sheetList;
    }

    public void addSheet(BaseSheet<T> sheet){
        if(sheetList==null){
            sheetList = new ArrayList<>();
        }
        sheetList.add(sheet);
    }

    public BaseSheet<T> createSheet(int sheetIndex, String sheetName){
        BaseSheet<T> sheet = new BaseSheet<>(sheetIndex, sheetName, this);
        addSheet(sheet);
        return sheet;
    }

}
